package leetcode_181_200;

public class rotate_189 {
    public void rotate(int[] nums, int k) {
        int n=nums.length;
        k=k%n;
        swap(nums,0,n-1);
        swap(nums,0,k-1);
        swap(nums,k,n-1);
        return;
    }
    public void swap(int[] nums,int l,int r){
        for(int i=0;i<(r-l+1)/2;i++){
            int t=nums[l+i];
            nums[l+i]=nums[r-i];
            nums[r-i]=t;
        }
    }
}
